﻿using FreeFlow.Administration;

using System.Diagnostics;
using System.Windows.Forms;

namespace FreeFlowAdministrator
{
  public partial class EventLogEntryControl : System.Windows.Forms.UserControl
  {
    public EventLogEntryControl()
    {
      InitializeComponent();

      UIActionList actionList = new UIActionList();
      actionList.Add("Copy to clipboard", "Copy the event log entry to the clipboard", 
        new ActionExecuteDelegate(CopyToClipboard));
      uiActionsControl.Actions = actionList;
    }

    private EventLogEntry entry;
    public void LoadEntry(EventLogEntry entry)
    {
      this.entry = entry;
      timeLabel.Text = entry.TimeWritten.ToString();
      typeLabel.Text = entry.EntryType.ToString();
      categoryLabel.Text = entry.Category;
      messageLabel.Text = entry.Message;
    }

    private string CopyToClipboard()
    {
      Clipboard.SetDataObject(entry.ToClipboardString(), true);
      return null;
    }
  }
}
